package com.carsa.blackberry.domain.services.webServices;

import java.rmi.RemoteException;
import java.util.Vector;

import javax.xml.rpc.Stub;

import com.carsa.blackberry.MainKeys;
import com.carsa.blackberry.domain.services.webServices.impl.ZSdareEntrega.ZSdareEntregable;
import com.carsa.blackberry.domain.services.webServices.impl.ZSdareEntrega.ZWS_SDARE_ENTREGA1_Stub;
import com.carsa.blackberry.util.Logger;

/**
 * @author Nahuel Barrios.
 * @since 26/08/2010.
 * @version 1.0
 */
public class ZSdareEntrega_Service implements WebService, ZSdareEntregable {

    public Object invokeWebService() {
	return null;
    }

    public Object invokeWebService(Object parameters) {
	Object[] parametersArray = null;

	if (parameters.getClass().equals(Vector.class))
	    parametersArray = this.parseParameters((Vector) parameters);

	return this.invokeWebService(parametersArray);
    }

    public Object invokeWebService(Object[] parametersArray) {
	ZWS_SDARE_ENTREGA1_Stub ws = new ZWS_SDARE_ENTREGA1_Stub();

	ws._setProperty(Stub.USERNAME_PROPERTY, MainKeys.WEB_SERVICES_USERNAME);
	ws._setProperty(Stub.PASSWORD_PROPERTY, MainKeys.WEB_SERVICES_PASSWORD);

	try {
	    return ws.ZSdareEntrega((String) parametersArray[0]);
	}
	catch (RemoteException e) {
	    Logger.logError(e);
	}
	catch (Exception anException) {
	    Logger.logError(Logger.getLocationMessageFor(this, "invokeWebService()")
		    + " intentando ejecutar el Web Service", anException);
	}
	return null;
    }

    public Object[] parseParameters(Vector parameters) {
	return new Object[] { parameters.elementAt(0) };// ILegaj
    }

    public Object[] parseParameters(String xmlParameters) {
	return null;
    }

    public String getName() {
	return MainKeys.WS_NAME_ZSDARE_ENTREGA;
    }

}
